<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%
    String path = request.getContextPath();
    String basePath = request.getScheme() + "://"
            + request.getServerName() + ":" + request.getServerPort()
            + path + "/";
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<base href="<%=basePath%>">
<title>个单激活</title>
<%@ include file="/WEB-INF/jsp/common/common.jsp"%>
<link rel="stylesheet" href="css/zTreeStyle/zTreeStyle.css">
<link rel="stylesheet" href="css/jquery.datetimepicker.css" type="text/css" />
<link rel="stylesheet" href="css/poshytip/tip-yellowsimple/tip-yellowsimple.css" type="text/css" />
<script type="text/javascript" src="js/jquery.datetimepicker.js"></script>
<script src="js/jquery.validate.js" type="text/javascript"></script>
<script src="js/jquery.divbox.js" type="text/javascript"></script>
<script src="js/json2.js" type="text/javascript"></script>
<script type="text/javascript" src="js/poshytip/jquery.poshytip.js"></script>
<script type="text/javascript" src="js/checkPppUnit.js"></script>
<script type="text/javascript" src="js/jquery.ztree.core-3.5.js"></script>
<script type="text/javascript" src="js/publicFuncton.js"></script>
<script type="text/javascript" src="js/jquery.ztree.excheck-3.5.js"></script>
<style type="text/css">
.scroll_body {
    height: 350px;
    overflow: scroll;
    overflow-x: hidden;
    padding: 20px 100px 0;
    margin-bottom: 20px;
}
.setp {
    margin-bottom: 20px
}
.input_text {
    width: 250px;
}
.insLineC{
    border-bottom: 1px solid #d7dce4;
    margin-top:10px;
    margin-bottom: 10px;
}
.td_label {
    text-align: right;
    padding-right: 10px;
}
</style>
<script type="text/javascript">
var MAX_DAYS,MIN_DAYS,UNIR_PP,MAX_DELAY_DAY,MIN_DELAY_DAY,INSTANT,PPP_UNIT,DMY_DESC;
var flag;
var global_SPECIAL_INFO = '';
var riskMainType='';
function init() {
    initValidateData();
}
function initValidateData(){
    //根据投保方案初始化最大天数,最小天数,最大份数,最大延长天数
//     $("#trip").css('border','1px solid #c3c3c3');
//     $("#trip").poshytip('hide');
//     $('#anesthType').css('border','1px solid #c3c3c3');
//     $('#anesthType').poshytip('hide');
//     $('#studentType').css('border','1px solid #c3c3c3');
//     $('#studentType').poshytip('hide');
//     $('#schoolType').css('border','1px solid #c3c3c3');
//     $('#schoolType').poshytip('hide');
//     $('#vehicleNature').css('border','1px solid #c3c3c3');
//     $('#vehicleNature').poshytip('hide');
//     $('#borrowTime').css('border','1px solid #c3c3c3');
//     $('#borrowTime').poshytip('hide');
//     $('#repayTime').css('border','1px solid #c3c3c3');
//     $('#repayTime').poshytip('hide');
//     $('#loanBankSitename').css('border','1px solid #c3c3c3');
//     $('#loanBankSitename').poshytip('hide');
//     $('#rationPeriod').css('border','1px solid #c3c3c3');
//     $('#rationPeriod').poshytip('hide');
    $('#departureTime').css('border','1px solid #c3c3c3');
    $('#departureTime').poshytip('hide');
    $('#arrivalTime').css('border','1px solid #c3c3c3');
    $('#arrivalTime').poshytip('hide');
    $('#plateNum').css('border','1px solid #c3c3c3');
    $('#plateNum').poshytip('hide');
    $('#seatNum').css('border','1px solid #c3c3c3');
    $('#seatNum').poshytip('hide');
    // $('#useNature').css('border','1px solid #c3c3c3');
    // $('#useNature').poshytip('hide');
    MAX_DAYS = $('#MAX_DAYS').val();
    MIN_DAYS = $('#MIN_DAYS').val();
    UNIR_PP = $('#UNIR_PP').val();
    MAX_DELAY_DAY = $('#MAX_DELAY_DAY').val();
    MIN_DELAY_DAY = $('#MIN_DELAY_DAY').val();
    INSTANT = $('#INSTANT').val();
    PPP_UNIT = $('#PPP_UNIT').val();
    global_SPECIAL_INFO = $('#global_SPECIAL_INFO').val();
    riskMainType=$('#riskMainType').val();
    if(PPP_UNIT=='y'){
        DMY_DESC = '保险年数：';
    }else if(PPP_UNIT=='m'){
        DMY_DESC = '保险月数：';
    }else{
        DMY_DESC = '保险天数：';
    }
//     //麻醉类型
//     if(global_SPECIAL_INFO == '1'){
//         $("#anesthTypeList").show();
//     }else{
//         $("#anesthTypeList").hide();
//     }
//     //学平险
//     if(riskMainType == '1'){
//         $("#learning").show();
//     }else{
//         $("#learning").hide();
//     }
//     //旅意险
//     if(riskMainType == '3'){
//         $("#tripId").show();
//     }else{
//         $("#tripId").hide();
//     }
    //驾乘险
    if(riskMainType == '2'&&global_SPECIAL_INFO==null){
        $("[name='drivingInfo']").show();
        $("[name='drivingInfo1']").show();
        $("[name='seatNuminfo']").show();
        $("[name='redshow']").show();
        $("#drivingShow").show();
    }else if(riskMainType == '2'&&global_SPECIAL_INFO=='0'){
    	 $("[name='drivingInfo']").hide();
         $("[name='drivingInfo1']").show();
         $("[name='seatNuminfo']").hide();
         $("[name='redshow']").hide();
    	 $("#drivingShow").hide();
    }else{
        $("[name='drivingInfo']").hide();
        $("[name='drivingInfo1']").hide();
        $("[name='seatNuminfo']").hide();
        $("[name='redshow']").show();
        $("#drivingShow").hide();
    }
    //驾意险
    if(riskMainType == '9'||riskMainType == '2'){
        $("#mainVehicleNatureId").show();
    }else{
        $("#mainVehicleNatureId").hide();
    }
//     //借意险
//     if(riskMainType == '6'){
//         $("[name='loanInfo']").show();
//         $('#borrowTime').datetimepicker({lang:'ch',validateOnBlur:false,timepicker:false,format:'Y-m-d',onChangeDateTime:clearTipBorrow,scrollMonth:false,scrollTime:false});
//         $('#repayTime').datetimepicker({lang:'ch',validateOnBlur:false,timepicker:false,format:'Y-m-d',onChangeDateTime:clearTipRepay,scrollMonth:false,scrollTime:false});
//     }else{
//         $("[name='loanInfo']").hide();
//     }
//     function clearTipBorrow(){
//         if($("#borrowTime").val()!=''){
//             $("#borrowTime").css('border','1px solid #c3c3c3');
//             $("#borrowTime").poshytip('hide'); 
//         }
//     }
//     function clearTipRepay(){
//         if($("#repayTime").val()!=''){
//             $("#repayTime").css('border','1px solid #c3c3c3');
//             $("#repayTime").poshytip('hide'); 
//         }
//     }
    //乘意险
    if(riskMainType == '7'){
        $("[name='ticketInfo']").show();
        $('#departureTime').datetimepicker({lang:'ch',validateOnBlur:false,timepicker:true,step:1,format:'Y-m-d H:i:00',minDate:'0',onChangeDateTime:clearDepartureTime,scrollMonth:false,scrollTime:false});
        $('#arrivalTime').datetimepicker({lang:'ch',validateOnBlur:false,timepicker:true,step:1,format:'Y-m-d H:i:00',minDate:'0',onChangeDateTime:clearArrivalTime,scrollMonth:false,scrollTime:false});
    }else{
        $("[name='ticketInfo']").hide();
    }
    function clearDepartureTime(){
        if($("#departureTime").val()!=''){
            $("#departureTime").css('border','1px solid #c3c3c3');
            $("#departureTime").poshytip('hide'); 
        }
    }
    function clearArrivalTime(){
        if($("#arrivalTime").val()!=''){
            $("#arrivalTime").css('border','1px solid #c3c3c3');
            $("#arrivalTime").poshytip('hide'); 
        }
    }
//     //附加高铁意外险
//     if(riskMainType == '8'){
//         $("[name='trainInfo']").show();
//         $('#departureTime').datetimepicker({lang:'ch',validateOnBlur:false,timepicker:false,format:'Y-m-d H:i:s',onChangeDateTime:clearDepartureTime,scrollMonth:false,scrollTime:false});
//         $('#arrivalTime').datetimepicker({lang:'ch',validateOnBlur:false,timepicker:false,format:'Y-m-d H:i:s',onChangeDateTime:clearArrivalTime,scrollMonth:false,scrollTime:false});
//     }else{
//         $("[name='trainInfo']").hide();
//     }
    var pricelessType=$('#pricelessType').val();
    //进度条处理
    if(pricelessType=='1'){
         stepConObj.curStepIndex=1;//当前已完成索引位置
         stepConObj.stepContentFlag="2";//1非见费和2见费标识
         stepControl(stepConObj);
    }else{
         stepConObj.curStepIndex=1;//当前已完成索引位置
         stepConObj.stepContentFlag="1";//1非见费和2见费标识
         stepControl(stepConObj);
    }
    
//     if($("#LAGALFALG").val()=='1'){
//         $("#lagalFlag").hide();
//     }else{
//         $("#lagalFlag").show();
//     }
    //默认处理
    defaultInterface();
    changeTbrIdType();
    if($("#editFlag").val()!='edit'){
        $("#isLagal").attr('checked',true);
    }

    //是否法定
    if($("#isLagal").prop('checked')==true){
        $(".appendBen").hide();
        $("#isLagal").val(1);
    }else{
        $(".appendBen").show();
        $("#isLagal").val(0);
    }
}
function defaultInterface(){
    if(MAX_DAYS==MIN_DAYS){
        $("#dayCount").attr("readonly",true);
    }
    if("${editFlag}"!='edit'){
        if(PPP_UNIT=='y'){
            $("#dayCount").val(MAX_DAYS);
        }else if(PPP_UNIT=='m'){
            $("#dayCount").val(MAX_DAYS);
        }else{
            if(MAX_DAYS==366){
                $("#dayCount").val(365);
            }else{
                $("#dayCount").val(MAX_DAYS);
            }
        }

        if(INSTANT=='Y'){
            $(".select1").attr('checked',true);
            $('#effDate').datetimepicker({lang:'ch',validateOnBlur:false,timepicker:true,format:'Y-m-d H:00:00',minDate:'0',onChangeDateTime:changeTermDate,scrollMonth:false,scrollTime:false});
            $("#effDate").unbind('mousewheel');
            $('#effDate').val(getDefaultDate(new Date(),0,1));
        }else{
            $(".select2").attr('checked',true);
            $('#effDate').datetimepicker({lang:'ch',validateOnBlur:false,timepicker:false,format:'Y-m-d H:00:00',minDate:MIN_DELAY_DAY,onChangeDateTime:changeTermDate,scrollMonth:false,scrollTime:false});
            $("#effDate").unbind('mousewheel');
            $('#effDate').val(getDefaultDate(new Date(),0,1+Number(MIN_DELAY_DAY)));
            $(".select1").attr('disabled',true);
        }

        var effDate = $('#effDate').val();
        effDate = effDate+"";
        var strdate = effDate; 
        strdate = strdate.replace(/-/g,"/");
        var EDate = new Date(strdate);

        if(PPP_UNIT=='y'){
            EDate.calTermDateByMonthOrYear(effDate,'Y',MAX_DAYS,INSTANT);
        }else if(PPP_UNIT=='m'){
            EDate.calTermDateByMonthOrYear(effDate,'M',MAX_DAYS,INSTANT);
        }else{
            $("#termDate").val(getDefaultDate(new Date(),$("#dayCount").val(),1));
        }
    }else{
    	if(INSTANT=='N'){
            $(".select1").attr('disabled',true);
        }
        var edate = $("#effDate").val();
        edate = edate+"";
        edate = edate.substring(0,10);
        var tdate = $("#termDate").val();
        tdate = tdate+"";
        tdate = tdate.substring(0,10);

        if(PPP_UNIT=='y'){
            edate = edate.replace(/-/g,"/");
            var dateS = new Date(edate);
            tdate = tdate.replace(/-/g,"/");
            var dateE = new Date(tdate);
            var days = getDateDiff(dateS,dateE);
            $('#dayCount').val(Math.round(days/365));
        }else if(PPP_UNIT=='m'){
            $('#dayCount').val(getMonthDiff(edate,tdate));
        }
        
    }
    
    $('#globalDMY').html(DMY_DESC);
}

//根据起保日期带出终止日期
function changeTermDate(){
    $('#effDate').css('border','1px solid #c3c3c3');
    $('#effDate').poshytip('hide'); 
    var dayCount = $("#dayCount").val();
    var effDate = $("#effDate").val();
    if(effDate.length==19){
        if(validateDate(effDate)==false) return;
        if(dayCount!=''){
            var realSignFlag = $("input[name='realSignFlag']:checked").val();
            var date = new Date(effDate.replace(/-/g, "/"));
            effDate = effDate+"";
            if(PPP_UNIT=='y'){
                date.calTermDateByMonthOrYear(effDate,'Y',dayCount,realSignFlag);
            }else if(PPP_UNIT=='m'){
                date.calTermDateByMonthOrYear(effDate,'M',dayCount,realSignFlag);
            }else{
                $("#termDate").val(getDefaultDate(date,dayCount,0));
            }
        }
    }else{
        $('#effDate').css('border','1px solid red');
        $('#effDate').poshytip('update', '起保时间不正确');
        $('#effDate').poshytip('show'); 
    }
}

$(function(){
    $('input,select').poshytip({
        className: 'tip-yellowsimple',
        showOn: 'none',
        alignTo: 'target',
        alignX: 'right',
        offsetX: 20,
        offsetY: -26,
        showTimeout: 100
    });
    $('.notNullClass').bind('change',function(){
        if($(this).val()!=''){
            $(this).css('border','1px solid #c3c3c3');
            $(this).poshytip('hide');
            if($(this).attr('id')=='chassisNum'){
                $('#plateNum').css('border','1px solid #c3c3c3');
                $('#plateNum').poshytip('hide');
            }
        }
        
    });
    init();
    //驾意险时不显示被保人信息
    if(!(riskMainType=='2'&&global_SPECIAL_INFO==null)){
        //初始化被保人显隐藏
        var relWithInsuredFlag = $('#relWithInsuredFlag').val();
        if(relWithInsuredFlag=='1'){
            $(".appInsuredClass").hide();
        }else{
            $(".appInsuredClass").show();
        }
        //投保人与被保人关系初始化
        var relWithInsured1 = $("#relWithInsured1").val();
        if(relWithInsured1=='01'){
            $(".appInsuredClass").hide();
        }else{
            $(".appInsuredClass").show();
        }
    }else{
    	$(".appInsuredClass").hide();
    	$("#commonInsure").hide();
    }
    //出生日期初始化
    $('#clientBir1,#clientBir2').datetimepicker({lang:'ch',validateOnBlur:false,timepicker:false,format:'Y-m-d',maxDate:'0',onChangeDateTime:changeDate,scrollMonth:false,scrollTime:false,scrollInput:false});
    //初始化即时起保引起时间显示
    if('${facadeAppForm.realSignFlag}'=='Y'){
        $('#effDate').datetimepicker({lang:'ch',validateOnBlur:false,timepicker:true,format:'Y-m-d H:00:00',minDate:'0',minTime:'0',onChangeDateTime:changeTermDate,scrollMonth:false,scrollTime:false});
    }else if('${facadeAppForm.realSignFlag}'=='N'){
        $('#effDate').datetimepicker({lang:'ch',validateOnBlur:false,timepicker:false,format:'Y-m-d H:00:00',minDate:MIN_DELAY_DAY,minTime:'0',onChangeDateTime:changeTermDate,scrollMonth:false,scrollTime:false});
    }
    //点击即时起保引起时间显示
    $(".realSignFlag").bind('click',function(){
        if($(this).val()=='Y'){
            $('#effDate').datetimepicker({lang:'ch',validateOnBlur:false,timepicker:true,format:'Y-m-d H:00:00',minDate:'0',minTime:'0',onChangeDateTime:changeTermDate,scrollMonth:false,scrollTime:false});
            $('#effDate').val(getDefaultDate(new Date(),0,1));
        }else{
            $('#effDate').datetimepicker({lang:'ch',validateOnBlur:false,timepicker:false,format:'Y-m-d H:00:00',minDate:MIN_DELAY_DAY,minTime:'0',onChangeDateTime:changeTermDate,scrollMonth:false,scrollTime:false});
            $('#effDate').val(getDefaultDate(new Date(),0,1+Number(MIN_DELAY_DAY)));
        }
        
        var dayCount = $("#dayCount").val();
        var effDate =$('#effDate').val(); 
        var date = new Date(effDate.replace(/-/g, "/"));
        effDate = effDate+"";
        if(PPP_UNIT=='y'){
            date.calTermDateByMonthOrYear(effDate,'Y',dayCount,$(this).val());
        }else if(PPP_UNIT=='m'){
            date.calTermDateByMonthOrYear(effDate,'M',dayCount,$(this).val());
        }else{
            $("#termDate").val(getDefaultDate(new Date(),$("#dayCount").val(),1));
        }
    });
    //投保人与被保人关系 选择与被保人关系清空被保人信息
    $("#relWithInsured1").bind('change',function(){
        var relWithInsured1 = $(this).val();
        if(relWithInsured1=='01'){
            $(".appInsuredClass").hide();
        }else{
            $(".appInsuredClass").show();
        }
        $("#clientName2").val('');
        $("#idType").get(0).selectedIndex=0;
        $("#idNo").val('');
        $("#clientBir2").val('');
        $("input[name='sex2']:checked").removeAttr("checked");
        $("#workIdBbr").val('');
        $("#workNameBbr").val('');
    });
    //电子邮箱校验
    $("#email").bind('change',function(){
        var email = $(this).val();
        if(email!=''){
            var emailReg1 = /^([a-zA-Z0-9]+[_|\-|\.]?)*[a-zA-Z0-9]+@([a-zA-Z0-9]+[_|\-|\.]?)*[a-zA-Z0-9]+\.[a-zA-Z]{2,3}$/g;
            if(emailReg1.test(email)){
                $(this).css('border','1px solid #c3c3c3');
                $(this).poshytip('hide');
            }else{
                $(this).css('border','1px solid red');
                $(this).poshytip('update', '电子邮箱格式错误');
                $(this).poshytip('show'); 
            }
        }else{
            $(this).css('border','1px solid #c3c3c3');
            $(this).poshytip('hide');
        }
    });
    //投保人证件类型
    $('#certificateType').change(function(){
        //$('#certificateCode').val('');
        if($(this).val()!="01"){
           $('#certificateCode').css('border','1px solid #c3c3c3');
           $('#certificateCode').poshytip('hide'); 
        }
     });
//     $("#anesthType").bind('change',function(){
//         if(global_SPECIAL_INFO == '1'){
//             if($(this).val()==""){
//                 $('#anesthType').css('border','1px solid red');
//                 $('#anesthType').poshytip('update', '请选择麻醉类型');
//                 $('#anesthType').poshytip('show'); 
//             }else{
//                 $("#anesthType").css('border','1px solid #c3c3c3');
//                 $("#anesthType").poshytip('hide');
//             }
//         }
//     });
//     $("#studentType").bind('change',function(){
//         if(riskMainType == '1'){
//             if($(this).val()==""){
//                 $('#studentType').css('border','1px solid red');
//                 $('#studentType').poshytip('update', '请选择学生类别');
//                 $('#studentType').poshytip('show'); 
//             }else{
//                 $("#studentType").css('border','1px solid #c3c3c3');
//                 $("#studentType").poshytip('hide');
//             }
//         }
//     });
//     $("#schoolType").bind('change',function(){
//         if( == '1'){
//             if($(this).val()==""){
//                 $('#schoolType').css('border','1px solid red');
//                 $('#schoolType').poshytip('update', '请选择学校类别');
//                 $('#schoolType').poshytip('show'); 
//             }else{
//                 $("#schoolType").css('border','1px solid #c3c3c3');
//                 $("#schoolType").poshytip('hide');
//             }
//         }
//     });
    //被保人证件类型
    $('#idType').change(function(){
        if($(this).val()!="01"){
            $("#idNo").css('border','1px solid #c3c3c3');
            $("#idNo").poshytip('hide');
        }
    });
    //投保人身份证
    $("#certificateCode").bind('change',function(){
        var cc = $(this).val();
        if($("#certificateType").val()=='01'){
            if(identityCodeValid(cc,'certificateCode')){
                $('#certificateCode').css('border','1px solid #c3c3c3');
                $('#certificateCode').poshytip('hide');
                if(cc.length==15){
                    $("#clientBir1").val("19"+cc.substr(6,2)+"-"+cc.substr(8,2)+"-"+cc.substr(10,2));
                    if (parseInt(cc.substr(13, 1)) % 2 == 1) {
                        $("#sexId1").prop('checked',true);
                    } else {
                        $("#sexId2").prop('checked',true);
                    } 
                }
                if(cc.length==18){
                    $("#clientBir1").val(cc.substr(6,4)+"-"+cc.substr(10,2)+"-"+cc.substr(12,2));
                    if (parseInt(cc.substr(16, 1)) % 2 == 1) {
                        $("#sexId1").prop('checked',true);
                    } else {
                        $("#sexId2").prop('checked',true);
                    } 
                }
                $("#clientBir1").css('border','1px solid #c3c3c3');
                $("#clientBir1").poshytip('hide'); 
                $("#sexId2").poshytip('hide'); 
            }
        }else if($("#certificateType").val()=='05'&&cc.length==18){
            $('#certificateCode').css('border','1px solid #c3c3c3');
            $('#certificateCode').poshytip('hide');
            if(identityCodeValidToBack(cc)){
                $("#clientBir1").val(cc.substr(6,4)+"-"+cc.substr(10,2)+"-"+cc.substr(12,2));
                if (parseInt(cc.substr(16, 1)) % 2 == 1) {
                    $("#sexId1").prop('checked',true);
                } else {
                    $("#sexId2").prop('checked',true);
                } 
            }
        }else{
            $('#certificateCode').css('border','1px solid #c3c3c3');
            $('#certificateCode').poshytip('hide');
        }
    });
    
//     //行程/航班事件
//     $("#trip").bind('change',function(){
//         if(riskMainType == '3'){
// 	        var trip = $(this).val();
// 	        if(trip==''){
// 	            $(this).css('border','1px solid red');
// 	            $(this).poshytip('update', '请填写行程/航班');
// 	            $(this).poshytip('show'); 
// 	            return ;
// 	        }else{
// 	            $(this).css('border','1px solid #c3c3c3');
// 	            $(this).poshytip('hide'); 
// 	        }
//         }
//     });
    //车辆性质
    $("#mainVehicleNature").bind('change',function(){
        if(riskMainType == '9'||riskMainType == '2'){
            var mainVehicleNature = $(this).val();
            if(mainVehicleNature==''){
	            $(this).css('border','1px solid red');
	            $(this).poshytip('update', '请填写车辆性质');
	            $(this).poshytip('show'); 
	            return ;
	        }else{
	            $(this).css('border','1px solid #c3c3c3');
	            $(this).poshytip('hide'); 
	        }
        }
    });
    //发车时间
    $("#departureTime").bind('change',function(){
        if(riskMainType == '7'){
            var departureTime = $(this).val();
            if(departureTime==''){
                $(this).css('border','1px solid red');
                $(this).poshytip('update', '请选择发车时间');
                $(this).poshytip('show'); 
                return ;
            }else{
                var now = new Date;
                now.setMinutes (now.getMinutes () + 10);
                var nowDate=now.getFullYear()+"-"+(((now.getMonth()+1)<10)?("0"+(now.getMonth()+1)):(now.getMonth()+1))+"-"+comple_Zero(now.getDate())+" "+comple_Zero(now.getHours())+":"+comple_Zero(now.getMinutes())+":00";
                if(compareTo(nowDate,departureTime)){
                    $(this).css('border','1px solid #c3c3c3');
                    $(this).poshytip('hide'); 
                }else{
                    $(this).css('border','1px solid red');
                    $(this).poshytip('update', '发车时间要大于系统时间');
                    $(this).poshytip('show'); 
                    return ;
                }
            }
        }
    });
    //到达时间
    $("#arrivalTime").bind('change',function(){
        if(riskMainType == '7'){
            var arrivalTime = $(this).val();
            if(arrivalTime==''){
                $(this).css('border','1px solid red');
                $(this).poshytip('update', '请选择到达时间');
                $(this).poshytip('show'); 
                return ;
            }else{
                var now = new Date;
                now.setMinutes (now.getMinutes () + 10);
                var nowDate=now.getFullYear()+"-"+(((now.getMonth()+1)<10)?("0"+(now.getMonth()+1)):(now.getMonth()+1))+"-"+comple_Zero(now.getDate())+" "+comple_Zero(now.getHours())+":"+comple_Zero(now.getMinutes())+":00";
                if(compareTo(nowDate,arrivalTime)){
                    $(this).css('border','1px solid #c3c3c3');
                    $(this).poshytip('hide'); 
                }else{
                    $(this).css('border','1px solid red');
                    $(this).poshytip('update', '到达时间要大于系统时间');
                    $(this).poshytip('show'); 
                    return ;
                }
            }
        }
    });
    changeTbrIdType();
    //被保人身份证
    $("#idNo").bind('change',function(){ 
        var cc = $(this).val();
        if($("#idType").val()=='01'){
            if(identityCodeValid(cc,'idNo')){
                $('#idNo').css('border','1px solid #c3c3c3');
                $('#idNo').poshytip('hide');
                if(cc.length==15){
                    $("#clientBir2").val("19"+cc.substr(6,2)+"-"+cc.substr(8,2)+"-"+cc.substr(10,2));
                    if (parseInt(cc.substr(13, 1)) % 2 == 1) {
                        $("#sexId3").prop('checked',true);
                    } else {
                        $("#sexId4").prop('checked',true);
                    } 
                }
                if(cc.length==18){
                    $("#clientBir2").val(cc.substr(6,4)+"-"+cc.substr(10,2)+"-"+cc.substr(12,2));
                    if (parseInt(cc.substr(16, 1)) % 2 == 1) {
                        $("#sexId3").prop('checked',true);
                    } else {
                        $("#sexId4").prop('checked',true);
                    } 
                }
                $('#clientBir2,#sexId4').css('border','1px solid #c3c3c3');
                $('#clientBir2,#sexId4').poshytip('hide');
            }
        }else if($("#idType").val()=='05'&&cc.length==18){
            $('#idNo').css('border','1px solid #c3c3c3');
            $('#idNo').poshytip('hide');
            if(identityCodeValidToBack(cc)){
                $("#clientBir2").val(cc.substr(6,4)+"-"+cc.substr(10,2)+"-"+cc.substr(12,2));
                if (parseInt(cc.substr(16, 1)) % 2 == 1) {
                    $("#sexId3").prop('checked',true);
                } else {
                    $("#sexId4").prop('checked',true);
                } 
                $('#clientBir2,#sexId4').css('border','1px solid #c3c3c3');
                $('#clientBir2,#sexId4').poshytip('hide');
            }
        }else{
            $('#idNo').css('border','1px solid #c3c3c3');
            $('#idNo').poshytip('hide');
        }
    });
    
    //天数改变引起终保日期改变
    $("#dayCount").bind('change',function() {
	    var dayCount = $(this).val();
	    if (dayCount == '') {
	        $(this).css('border', '1px solid red');
	        $(this).poshytip('update', '请填写' + DMY_DESC);
	        $(this).poshytip('show');
	        return;
	    }
	    if (isNaN(dayCount)) {
	        $(this).css('border', '1px solid red');
	        $(this).poshytip('update', DMY_DESC + '应为整数');
	        $(this).poshytip('show');
	        return;
	    }
	    if (dayCount-MIN_DAYS<0) {
	        $(this).css('border', '1px solid red');
	        $(this).poshytip('update',
	                DMY_DESC + "最小为" + MIN_DAYS);
	        $(this).poshytip('show');
	        return;
	    }
	    var MAXDAY = MAX_DAYS;
	    if (MAX_DAYS == 365)
	        MAXDAY = 366;
	    if (dayCount-MAXDAY>0) {
	        $(this).css('border', '1px solid red');
	        $(this).poshytip('update',
	                DMY_DESC + "最大为" + MAX_DAYS);
	        $(this).poshytip('show');
	        return;
	    }
	
	    var effDate = $("#effDate").val();
	    var dateCur = new Date(effDate.replace(/-/g, "/"));
	    if (dayCount == 366 && !isRunYear(dateCur)) {
	        $(this).css('border', '1px solid red');
	        $(this).poshytip('update', "平年保险天数最大为365天");
	        $(this).poshytip('show');
	        return;
	    }
	
	    $(this).css('border', '1px solid #c3c3c3');
	    $(this).poshytip('hide');
	    var effDate = $("#effDate").val();
	    if (dayCount != '' && effDate.length == 19) {
	        var realSignFlag = $(
	                "input[name='realSignFlag']:checked")
	                .val();
	        var date = new Date(effDate.replace(/-/g, "/"));
	        effDate = effDate + "";
	        if (PPP_UNIT == 'y') {
	            date.calTermDateByMonthOrYear(effDate, 'Y',
	                    dayCount, realSignFlag);
	        } else if (PPP_UNIT == 'm') {
	            date.calTermDateByMonthOrYear(effDate, 'M',
	                    dayCount, realSignFlag);
	        } else {
	            $("#termDate").val(
	                    getDefaultDate(date, dayCount, 0));
	        }
	    }
	});
    
//     //受益人证件类型
//     $('#idType3').change(function(){
//         $("#idNo3").css('border','1px solid #c3c3c3');
//         $("#idNo3").poshytip('hide');
//     });
});
function changeTbrIdType(){
	var idType=$("#appNature").val();
	var s = document.getElementById("certificateType").options;
	s.length=0;
	if(idType=="1"){
		var id=${id01};
		for(var i in id){
		   	s.add(new Option(id[i].codeName,id[i].code));
		}
	}else if(idType=="5"){
		var id=${id03};
		for(var i in id){
			s.add(new Option(id[i].codeName,id[i].code));
		}
	}else{
		var id=${id02};
		for(var i in id){
			s.add(new Option(id[i].codeName,id[i].code));
		}
	}
}
function compareTo(beginTime,endTime){
    var beginTimes = beginTime.substring(0,10).split('-');  
    var endTimes   =  endTime.substring(0,10).split('-');  
      
    beginTime = beginTimes[1]+'-'+beginTimes[2]+'-'+beginTimes[0]+' '+beginTime.substring(10,19);  
    endTime    = endTimes[1]+'-'+endTimes[2]+'-'+endTimes[0]+' '+endTime.substring(10,19);   
    var a =(Date.parse(endTime)-Date.parse(beginTime))/3600/1000;
    if(a<0){
        return false;
    }else if (a>0){
        return true;
    }else if (a==0){  
        return false;
    }  
 }
//关闭提示
function changeDate(){
    $("#clientBir1").css('border','1px solid #c3c3c3');
    $("#clientBir1").poshytip('hide'); 
    $("#clientBir2").css('border','1px solid #c3c3c3');
    $("#clientBir2").poshytip('hide'); 
}
//获取时间(时间,天数,下一个小时或者下一天)
function getDefaultDate(date,daySum,next){
    if(daySum==365){
        daySum = processDay(date,daySum);
    }
    var rsf = $("input[name='realSignFlag']:checked").val();
    var year = date.getFullYear();
    var month = (date.getMonth()+1)<10?('0'+(date.getMonth()+1)):(date.getMonth()+1);
    var day = date.getDate()<10?'0'+date.getDate():date.getDate();
    var hours = date.getHours()<10?'0'+date.getHours():date.getHours();
    if(rsf=='Y'){
        //即时起保
        date = new Date(year+"/"+month+"/"+day+" "+hours+":00:00");
        if(daySum==0){
            date = new Date(date.getTime()+next*60*60*1000);
        }else{
            date = new Date(date.getTime()+next*60*60*1000+daySum*24*60*60*1000);
        }
    }else{
        //非即时起保
        date = new Date(year+"/"+month+"/"+day+" 00:00:00");
        if(daySum==0){
            date = new Date(date.getTime()+next*24*60*60*1000);
        }else{
            date = new Date(date.getTime()+next*24*60*60*1000+(daySum-1)*24*60*60*1000);
        }
    }
    var year1 = date.getFullYear();
    var month1 = (date.getMonth()+1)<10?('0'+(date.getMonth()+1)):(date.getMonth()+1);
    var day1 = date.getDate()<10?'0'+date.getDate():date.getDate();
    var hours1 = date.getHours()<10?'0'+date.getHours():date.getHours();
    if(daySum==0){
        return year1+"-"+month1+"-"+day1+" "+hours1+":00:00";
    }else{
        if(rsf=='Y'){
            return year1+"-"+month1+"-"+day1+" "+hours1+":00:00";
        }else{
            return year1+"-"+month1+"-"+day1+" "+"24:00:00";
        }
    }
}
//对特殊的365天进行处理，如果包含瑞年2月，则返回366天
function processDay(date,daySum){
    if(date.getMonth()==1 && date.getDate()!=29){
        date = new Date(date.getTime()+1*24*60*60*1000);
    }
    var year = date.getFullYear();
    var month =  date.getMonth()+1;
    if(month>2){
        year = parseInt(year)+1;
    }
    if((year%4==0 && year%100!=0)||(year%100==0 && year%400==0)){
        daySum = parseInt(daySum)+1;
    }
    return daySum;
}
//校验投保日期
function validateDate(effDate){
    var beginDate = getDefaultDate(new Date(),0,1);
    var nowDate = new Date(beginDate.replace(/-/g,"/"));
    var newDate = new Date(effDate.replace(/-/g, "/"));
    var rsf = $("input[name='realSignFlag']:checked").val();
    if(newDate.getTime()<nowDate.getTime()){
        if(rsf=='Y'){
            $('#effDate').css('border','1px solid red');
            $('#effDate').poshytip('update', '即时起保时间为当前时间后整点时间');
            $('#effDate').poshytip('show'); 
            return false;
        }else{
            $('#effDate').css('border','1px solid red');
            $('#effDate').poshytip('update', '非即时起保时间至少第二天起');
            $('#effDate').poshytip('show'); 
            return false;
        }
    }
    if(newDate.getTime()-nowDate.getTime()<MIN_DELAY_DAY*24*60*60*1000){
        $('#effDate').css('border','1px solid red');
        $('#effDate').poshytip('update', "最短延保天数不能小于"+MIN_DELAY_DAY+"天");
        $('#effDate').poshytip('show'); 
        return false;
    }
    if(newDate.getTime()-nowDate.getTime()>MAX_DELAY_DAY*24*60*60*1000){
        $('#effDate').css('border','1px solid red');
        $('#effDate').poshytip('update', "最大延保天数不能超过"+MAX_DELAY_DAY+"天");
        $('#effDate').poshytip('show'); 
        return false;
    }
}
function clearBasicInfoNotice(){
    $('#dayCount,#clientName1,#certificateCode,#clientBir1,#sexId2').css('border','1px solid #c3c3c3');
    $('#dayCount,#clientName1,#certificateCode,#clientBir1,#sexId2').poshytip('hide'); 
}
function hiddedView(id){
    $("#"+id).poshytip('hide'); 
}
//校验出生日期
function validateIdCode(idNo,cBir,isSex,cBirName,viewFalg){
    var backFalg = true;
    var id="";
    if(viewFalg==1){
        id="certificateCode";
    }else if(viewFalg==2){
        id="idNo";
    }
    if(identityCodeValid(idNo,id)){
        var cB='';
        var sexFalg;
        if(idNo.length==15){
            cB = "19"+idNo.substr(6,2)+"-"+idNo.substr(8,2)+"-"+idNo.substr(10,2);
            if (parseInt(idNo.substr(13, 1)) % 2 == 1) {
                sexFalg = '1';
            } else {
                sexFalg = '2';
            } 
        }
        if(idNo.length==18){
            cB = idNo.substr(6,4)+"-"+idNo.substr(10,2)+"-"+idNo.substr(12,2);
            if (parseInt(idNo.substr(16, 1)) % 2 == 1) {
                sexFalg = '1';
            } else {
                sexFalg = '2';
            } 
        }
        if(cB!=cBir){
            backFalg = false;
            if(viewFalg==1){
                $('#clientBir1').css('border','1px solid red');
                $('#clientBir1').poshytip('update', cBirName+"出生日期与身份证不对应");
                $('#clientBir1').poshytip('show'); 
            }
            if(viewFalg==2){
                $('#clientBir2').css('border','1px solid red');
                $('#clientBir2').poshytip('update', cBirName+"出生日期与身份证不对应");
                $('#clientBir2').poshytip('show'); 
            }
        }
        if(sexFalg != isSex){
            backFalg = false;
            if(viewFalg==1){
                $('#sexId2').poshytip('update', cBirName+"性别与身份证不对应");
                $('#sexId2').poshytip('show'); 
            }
            if(viewFalg==2){
                $('#sexId4').poshytip('update', cBirName+"性别与身份证不对应");
                $('#sexId4').poshytip('show'); 
            }
            if(viewFalg==3){
                $('#sexId6').poshytip('update', cBirName+"性别与身份证不对应");
                $('#sexId6').poshytip('show'); 
            }
        }
    }else{
        backFalg = false;
    }
    return backFalg;
}
//是否闰年
function isRunYear(date){
    if(date.getMonth()==1 && date.getDate()!=29){
        date = new Date(date.getTime()+1*24*60*60*1000);
    }
    var year = date.getFullYear();
    var month =  date.getMonth()+1;
    if(month>2){
        year = parseInt(year)+1;
    }
    if((year%4==0 && year%100!=0)||(year%100==0 && year%400==0)){
        return true;
    }else{
        return false;
    }
}
function getBaseInfo(){
    var pmb={};
    pmb.insuPlanNo=$("#planNo").val();
    pmb.insuPlanNoDscp=$("#planName").val();
    pmb.realSignFlag=$("input:radio[name='realSignFlag']:checked").val();
    pmb.dayCount=$("#dayCount").val();
    pmb.unirPp="1";
    pmb.trip=$("#trip").val();
    pmb.effDate=$("#effDate").val();
    pmb.termDate=$("#termDate").val();
    pmb.totPremamt=$("#totPremamt").val();
    pmb.relWithInsured=$("#relWithInsured1").val();
    pmb.anesthType=$("#anesthType").val();
    pmb.mainVehicleNature=$("#mainVehicleNature").val();
    pmb.isLagal=$("#isLagal").val();
    pmb.partnerNo=$("#partnerNo").val();
//  借意险信息
//     pmb.borrowTime=$("#borrowTime").val();
//     pmb.repayTime=$("#repayTime").val();
//     pmb.loanBankSitename=$("#loanBankSitename").val();
//     pmb.bankLinkerName=$("#bankLinkerName").val();
//     pmb.bankLinkerPhone=$("#bankLinkerPhone").val();
//     pmb.repaidType=$("#repaidType").val();
//     pmb.loanWay=$("#loanWay").val();
    //驾乘险信息
    if(riskMainType=='2'){
        pmb.plateNum=$("#plateNum").val();
        pmb.chassisNum=$("#chassisNum").val();
        pmb.seatNum=$("#seatNum").val();
        // pmb.useNature=$("#useNature").val();
    }
      //乘意险信息
    if(riskMainType=='7'){
        pmb.trainNumber=$("#trainNumber").val();
        pmb.seatNumber=$("#seatNumber").val();
        pmb.departureTime=$("#departureTime").val();
        pmb.arrivalTime=$("#arrivalTime").val();
        pmb.ticketNumber=$("#ticketNumber").val();
        pmb.vehicle=$("#vehicle").val();
        pmb.ticketNo=$("#ticketNo").val();
        pmb.departureStation=$("#departureStation").val();
        pmb.arrivalStation=$("#arrivalStation").val();
    }
//     else if(riskMainType=='8'){
//         pmb.trainNumber=$("#trainNumber1").val();
//         pmb.seatNumber=$("#seatNumber1").val();
//         pmb.departureTime=$("#departureTime1").val();
//         pmb.arrivalTime=$("#arrivalTime1").val();
//         pmb.ticketNumber=$("#ticketNumber1").val();
//         pmb.vehicle=$("#vehicle1").val();
//         pmb.ticketNo=$("#ticketNo1").val();
//         pmb.departureStation=$("#departureStation1").val();
//         pmb.arrivalStation=$("#arrivalStation1").val();
//         pmb.rationPeriod=$("#rationPeriod").val();
//     }
    
    return pmb;
}
function getAppLicant(){//投保人信息
    var licant={};
    licant.clientName=$("#clientName1").val();
    licant.clientBir=$("#clientBir1").val();
    licant.certificateType=$("#certificateType").val();
    licant.certificateCode=$("#certificateCode").val();
    licant.sex=$("input[name='sex1']:checked").val();
    licant.linkmanTel=$("#linkmanTel1").val();
    licant.email=$("#email").val();
    licant.appNationality=$("#appNationality").val();
    licant.relWithInsured=$("#relWithInsured1").val();
    licant.workType=$("#workId").val();
    licant.appNature=$("#appNature").val();
    return licant;
}
function getInsured(){//被保人信息
    var relWithInsured1=$("#relWithInsured1").val();
    var insureds=new Array();
    var insured={};
    if(riskMainType!='2'||global_SPECIAL_INFO=='0'){
	    insured.relWithInsured=relWithInsured1;
	     if(relWithInsured1=="01"){//如果同投保人
	        insured.clientName=$("#clientName1").val();
	        insured.idType=$("#certificateType").val();
	        insured.idNo=$("#certificateCode").val();
	        insured.clientBir=$("#clientBir1").val(); 
	        insured.sex=$("input[name='sex1']:checked").val();
	        insured.clientTel=$("#linkmanTel1").val();
	        insured.insNationality=$("#appNationality").val();
	        insured.studentType=$("#studentType").val();
	        insured.schoolType=$("#schoolType").val();
	        insured.schoolNature=$("#schoolNature").val();
	        insured.workType=$("#workId").val();
	     }else{//不是本人则取被保人填报的信息
	        insured.clientName=$("#clientName2").val();
	        insured.idType=$("#idType").val();
	        insured.idNo=$("#idNo").val();
	        insured.clientBir=$("#clientBir2").val(); 
	        insured.sex=$("input[name='sex2']:checked").val();
	        insured.clientTel=$("#clientTel2").val();
	        insured.insNationality=$("#insNationality").val();
	        insured.studentType=$("#studentType").val();
	        insured.schoolType=$("#schoolType").val();
	        insured.schoolNature=$("#schoolNature").val();
            insured.workType=$("#workIdBbr").val();
	     }
	     insureds.push(insured);
    }
     return insureds;
}
//暂存接口
function tempSave(){
    if(false==validateData()) return ;
    var baseInfo=getBaseInfo();
    if(baseInfo==false)return false;
    var appLicant=getAppLicant();
    if(appLicant==false)return false;
    var insured=getInsured();
    if(insured==false)return false;
    var appNo = $("#appNo").val();
    var stagNo = $("#stagNo").val();
    $.openLoading_jhk();
    $.ajax({
        url : "activatedCard/single/saveTemporary",
        type : 'POST',
        async : true,
        dataType:'json',
        data:{"baseInfo":JSON.stringify(baseInfo),
              "appLicant":JSON.stringify(appLicant),
              "insured":JSON.stringify(insured),
              "appNoJm":appNo,
              "stagNoJm":stagNo
            },
        success : function(result){
            $.closeLoading();
            if("fail"==result.result){
                $.message("error", "系统错误,请联系管理员");
            }else if("success"==result.result){
                $("#stagNo").val(result.data[0]);
                $("#appNo").val(result.data[1]);
                $.message("success",result.message)
            }else{
                if(result.data != null){
                    $("#stagNo").val(result.data[0]);
                    $("#appNo").val(result.data[1]);
                }
                $.message("error", result.message);
            }
        }
    }); 
}
//投保预览接口
function previewSubmit(){
    if(false==validateData()) return ;
    var baseInfo=getBaseInfo();
    if(baseInfo==false)return false;
    var appLicant=getAppLicant();
    if(appLicant==false)return false;
    var insured=getInsured();
    if(riskMainType!='2'&&insured==false)return false;
    var appNo = $("#appNo").val();
    var stagNo = $("#stagNo").val();
    $.openLoading_jhk();
    $.ajax({
        url : "activatedCard/single/saveTemporary",
        type : 'POST',
        async : true,
        dataType:'json',
        data:{"baseInfo":JSON.stringify(baseInfo),
              "appLicant":JSON.stringify(appLicant),
              "insured":JSON.stringify(insured),
              "appNoJm":appNo,
              "stagNoJm":stagNo
            },
        success : function(result){
            if("fail"==result.result){
            	$.closeLoading();
                $.message("error", "系统错误,请联系管理员");
                return true;
            }else if("success"==result.result){
                $("#stagNo").val(result.data[0]);
                $("#appNo").val(result.data[1]);
                if(result.data[2]!=null){
               		$("#warnInfo").val(result.data[2]);
                }
                window.location.href='<%=path%>/activatedCard/single/previewSingle';
            }else{
                $.closeLoading();
                if(result.data != null){
                    $("#stagNo").val(result.data[0]);
                    $("#appNo").val(result.data[1]);
                }
                $.message("error", result.message);
            }
        }
    });
}
//数据校验
function validateData(){
    var backFlag = true;
    var realSignFlag = $("input[name='realSignFlag']:checked").val();
    if(realSignFlag==undefined){
        $.message("error","请选择是否即时起保");
        backFlag = false;
    }
    if(realSignFlag=='Y' && INSTANT=='N'){
        $.message("error","是否即时起保请选择否");
        backFlag = false;
    }   
    var dayCount = $("#dayCount").val();
    if(dayCount==''){
        $('#dayCount').css('border','1px solid red');
        $('#dayCount').poshytip('update', '请填写'+DMY_DESC);
        $('#dayCount').poshytip('show'); 
        backFlag = false;
    }
    if(isNaN(dayCount)){
        $('#dayCount').css('border','1px solid red');
        $('#dayCount').poshytip('update', DMY_DESC+'应为整数');
        $('#dayCount').poshytip('show'); 
        backFlag = false; 
    }
    if(dayCount-MIN_DAYS<0){
        $('#dayCount').css('border','1px solid red');
        $('#dayCount').poshytip('update', DMY_DESC+"最小为"+MIN_DAYS);
        $('#dayCount').poshytip('show');
        backFlag = false;
    }
    var MAXDAY1 = MAX_DAYS;
    if(MAX_DAYS==365) MAXDAY1=366;
    if(dayCount-MAXDAY1>0){
        $('#dayCount').css('border','1px solid red');
        $('#dayCount').poshytip('update', DMY_DESC+"最大为"+MAX_DAYS);
        $('#dayCount').poshytip('show');
        backFlag = false;
    }

    var effDate = $("#effDate").val();
    if(effDate==''){
        $('#effDate').css('border','1px solid red');
        $('#effDate').poshytip('update', '请选择起保日期');
        $('#effDate').poshytip('show');
        backFlag = false;
    }
    
    if(validateDate(effDate)==false) return false;
    
    var dateCur = new Date(effDate.replace(/-/g, "/"));
    if(dayCount==366 && !isRunYear(dateCur)){
        $('#dayCount').css('border','1px solid red');
        $('#dayCount').poshytip('update', "平年保险天数最大为365天");
        $('#dayCount').poshytip('show');
        backFlag = false;
    }
//     if(global_SPECIAL_INFO == 1){
//         var anesthType = $("#anesthType").val();
//         if(anesthType == ''){
//             $('#anesthType').css('border','1px solid red');
//             $('#anesthType').poshytip('update', '请选择麻醉类型');
//             $('#anesthType').poshytip('show'); 
//             backFlag = false; 
//         }
//     }
//     if(riskMainType == '1'){
//         var studentType = $("#studentType").val();
//         var schoolType = $("#schoolType").val();
//         if(studentType == ''){
//             $('#studentType').css('border','1px solid red');
//             $('#studentType').poshytip('update', '请选择学生类别');
//             $('#studentType').poshytip('show'); 
//             backFlag = false; 
//         }   
//         if(schoolType == ''){
//             $('#schoolType').css('border','1px solid red');
//             $('#schoolType').poshytip('update', '请选择学校类别');
//             $('#schoolType').poshytip('show'); 
//             backFlag = false; 
//         }
//     }
//     if(riskMainType == '3'){
//         var trip = $("#trip").val();
//         if(trip == ''){
//             $('#trip').css('border','1px solid red');
//             $('#trip').poshytip('update', '请填写行程/航班');
//             $('#trip').poshytip('show'); 
//             backFlag = false; 
//         }
//     }
    if(riskMainType == '2'){
       /*  var plateNum = $("#plateNum").val();
        var chassisNum = $("#chassisNum").val();
        if(plateNum == ''&&chassisNum==''){
            $('#plateNum').css('border','1px solid red');
            $('#plateNum').poshytip('update', '车牌号和车架号至少填写一项');
            $('#plateNum').poshytip('show'); 
            backFlag = false; 
        }
        var seatNum = $("#seatNum").val();
        if(seatNum == ''){
            $('#seatNum').css('border','1px solid red');
            $('#seatNum').poshytip('update', '请填写投保座位数');
            $('#seatNum').poshytip('show'); 
            backFlag = false; 
        } */
        // var useNature = $("#useNature").val();
        // if(useNature == ''){
        //     $('#useNature').css('border','1px solid red');
        //     $('#useNature').poshytip('update', '请选择车辆使用性质');
        //     $('#useNature').poshytip('show'); 
        //     backFlag = false; 
        // }
    }
    if(riskMainType == '7'){
        var departureTime = $("#departureTime").val();
        if(departureTime == ''){
            $('#departureTime').css('border','1px solid red');
            $('#departureTime').poshytip('update', '请选择发车时间');
            $('#departureTime').poshytip('show'); 
            backFlag = false; 
        }
        var arrivalTime = $("#arrivalTime").val();
        if(arrivalTime == ''){
            $('#arrivalTime').css('border','1px solid red');
            $('#arrivalTime').poshytip('update', '请选择到达时间');
            $('#arrivalTime').poshytip('show'); 
            backFlag = false; 
        }
        if(departureTime!=''&&arrivalTime!=''){
            var tdate = $("#termDate").val();
            if(!compareTo(departureTime,arrivalTime)){
                $('#arrivalTime').css('border','1px solid red');
                $('#arrivalTime').poshytip('update', '到达时间要大于发车时间');
                $('#arrivalTime').poshytip('show'); 
                backFlag = false; 
            }else if(tdate!=''&& compareTo(tdate,arrivalTime)){
                $('#arrivalTime').css('border','1px solid red');
                $('#arrivalTime').poshytip('update', '到达时间要小于终保日期');
                $('#arrivalTime').poshytip('show'); 
                backFlag = false; 
            }
        }
        if(effDate!=''&&departureTime!=''){
            if(compareTo(departureTime,effDate)){
                $('#departureTime').css('border','1px solid red');
                $('#departureTime').poshytip('update', '发车时间要大于起保日期');
                $('#departureTime').poshytip('show'); 
                backFlag = false; 
            }
        }
        
        var vehicle = $("#vehicle").val();
        if(vehicle == ''){
            $('#vehicle').css('border','1px solid red');
            $('#vehicle').poshytip('update', '请选择交通工具');
            $('#vehicle').poshytip('show'); 
            backFlag = false; 
        }
        var ticketNo = $("#ticketNo").val();
        if(ticketNo == ''){
            $('#ticketNo').css('border','1px solid red');
            $('#ticketNo').poshytip('update', '请填写客票号码');
            $('#ticketNo').poshytip('show'); 
            backFlag = false; 
        }
        var departureStation = $("#departureStation").val();
        if(departureStation == ''){
            $('#departureStation').css('border','1px solid red');
            $('#departureStation').poshytip('update', '请填写出发地点/起始站');
            $('#departureStation').poshytip('show'); 
            backFlag = false; 
        }
        var arrivalStation = $("#arrivalStation").val();
        if(arrivalStation == ''){
            $('#arrivalStation').css('border','1px solid red');
            $('#arrivalStation').poshytip('update', '请填写到达地点/到达站');
            $('#arrivalStation').poshytip('show'); 
            backFlag = false; 
        }
    }
//     if(riskMainType == '8'){
//         var departureTime = $("#departureTime").val();
//         if(departureTime == ''){
//             $('#departureTime').css('border','1px solid red');
//             $('#departureTime').poshytip('update', '请填写发车时间');
//             $('#departureTime').poshytip('show'); 
//             backFlag = false; 
//         }
//         var arrivalTime = $("#arrivalTime").val();
//         if(arrivalTime == ''){
//             $('#arrivalTime').css('border','1px solid red');
//             $('#arrivalTime').poshytip('update', '请填写到达时间');
//             $('#arrivalTime').poshytip('show'); 
//             backFlag = false; 
//         }
//         var rationPeriod = $("#rationPeriod").val();
//         if(rationPeriod == ''){
//             $('#rationPeriod').css('border','1px solid red');
//             $('#rationPeriod').poshytip('update', '请填写保障期间');
//             $('#rationPeriod').poshytip('show'); 
//             backFlag = false; 
//         }
//     }
    if(riskMainType == '9' || riskMainType == '2'){
        var mainVehicleNature = $("#mainVehicleNature").val();
        if(mainVehicleNature == ''){
            $('#mainVehicleNature').css('border','1px solid red');
            $('#mainVehicleNature').poshytip('update', '请填写车辆性质');
            $('#mainVehicleNature').poshytip('show');
            backFlag = false; 
        }
    }
//     if(riskMainType == '6'){
// 	    var borrowTime = $("#borrowTime").val();
// 	    if(borrowTime==''){
// 	        $('#borrowTime').css('border','1px solid red');
// 	        $('#borrowTime').poshytip('update', '请选择借款时间');
// 	        $('#borrowTime').poshytip('show');
// 	        backFlag = false;
// 	    }
// 	    var repayTime = $("#repayTime").val();
// 	    if(repayTime==''){
// 	        $('#repayTime').css('border','1px solid red');
// 	        $('#repayTime').poshytip('update', '请选择还款时间');
// 	        $('#repayTime').poshytip('show');
// 	        backFlag = false;
// 	    }
// 	    var loanBankSitename = $("#loanBankSitename").val();
// 	    if(loanBankSitename==''){
// 	        $('#loanBankSitename').css('border','1px solid red');
// 	        $('#loanBankSitename').poshytip('update', '请填写贷款银行网点名称');
// 	        $('#loanBankSitename').poshytip('show');
// 	        backFlag = false;
// 	    }
//     }

    var clientName1 = $("#clientName1").val();
    if(clientName1==''){
        $('#clientName1').css('border','1px solid red');
        $('#clientName1').poshytip('update', '请填写投保人姓名');
        $('#clientName1').poshytip('show'); 
        backFlag = false;
    }
    var certificateType = $("#certificateType").val();
    if(certificateType==''){
        $('#certificateType').css('border','1px solid red');
        $('#certificateType').poshytip('update', '请选择投保人证件类型');
        $('#certificateType').poshytip('show'); 
        backFlag = false;
    }
    var certificateCode = $("#certificateCode").val();
    if(certificateCode==''){
        $('#certificateCode').css('border','1px solid red');
        $('#certificateCode').poshytip('update', '请填写投保人证件号码');
        $('#certificateCode').poshytip('show'); 
        backFlag = false;
    }else if(certificateType=='01'){
        var isSex = $("input[name='sex1']:checked").val();
        var cBir = $("#clientBir1").val();
        if(!validateIdCode(certificateCode,cBir,isSex,'投保人',1)){
            backFlag = false;
        } 
    }
    var linkmanTel1 = $("#linkmanTel1").val();
    if(linkmanTel1==''){
        $('#linkmanTel1').css('border','1px solid red');
        $('#linkmanTel1').poshytip('update', '请选择投保人手机号码');
        $('#linkmanTel1').poshytip('show'); 
        backFlag = false;
    }
    var email = $("#email").val();
    if(email==''){
        $('#email').css('border','1px solid red');
        $('#email').poshytip('update', '请选择投保人邮箱');
        $('#email').poshytip('show'); 
        backFlag = false;
    }else{
        var emailReg = /^([a-zA-Z0-9]+[_|\-|\.]?)*[a-zA-Z0-9]+@([a-zA-Z0-9]+[_|\-|\.]?)*[a-zA-Z0-9]+\.[a-zA-Z]{2,3}$/g;
        if(!emailReg.test(email)){
            $('#email').css('border','1px solid red');
            $('#email').poshytip('update', '电子邮箱格式错误');
            $('#email').poshytip('show'); 
            backFlag = false;
        }
    }

    var cBir = $("#clientBir1").val();
    if(cBir==''){
        $('#clientBir1').css('border','1px solid red');
        $('#clientBir1').poshytip('update', '请选择投保人出生日期');
        $('#clientBir1').poshytip('show'); 
        backFlag = false;
    }
    var isSex = $("input[name='sex1']:checked").val();
    if(isSex==undefined){
        $("#sexId2").poshytip('update', '请选择投保人性别');
        $("#sexId2").poshytip('show'); 
        backFlag = false;
    }
    
    if(riskMainType != '2'||global_SPECIAL_INFO=='0'){
       var relWithInsured1 = $("#relWithInsured1").val();
       if(relWithInsured1==''){
           $('#relWithInsured1').css('border','1px solid red');
           $('#relWithInsured1').poshytip('update', '请选择投保人与被保人关系');
           $('#relWithInsured1').poshytip('show'); 
           backFlag = false;
       }
       if(relWithInsured1!='01'){
		   var clientName2 = $("#clientName2").val();
		   if(clientName2==''){
		       $('#clientName2').css('border','1px solid red');
		       $('#clientName2').poshytip('update', '请填写被保人姓名');
		       $('#clientName2').poshytip('show'); 
		       backFlag = false;
		   }
		   var idType = $("#idType").val();
		   if(idType==''){
		       $('#idType').css('border','1px solid red');
		       $('#idType').poshytip('update', '请选择被保人证件类型');
		       $('#idType').poshytip('show'); 
		       backFlag = false;
		   }
		   var cBir = $("#clientBir2").val();
		   if(cBir==''){
		       $('#clientBir2').css('border','1px solid red');
		       $('#clientBir2').poshytip('update', '请选择被保人出生日期');
		       $('#clientBir2').poshytip('show'); 
		       backFlag = false;
		   }
		   var isSex = $("input[name='sex2']:checked").val();
		   if(isSex==undefined){
		       $("#sexId4").poshytip('update', '请选择被保人性别');
		       $("#sexId4").poshytip('show'); 
		       backFlag = false;
		   }
		   var idNo = $("#idNo").val();
		   if(idNo==''){
		       $('#idNo').css('border','1px solid red');
		       $('#idNo').poshytip('update', '请填写被保人证件号码');
		       $('#idNo').poshytip('show'); 
		       backFlag = false;
		   }else if(idType=='01'){
		       if(!validateIdCode(idNo,cBir,isSex,'被保人',2)) backFlag = false;
		   }
       }
    }
    return backFlag;
}
function openWorkDiv(str) {
    flag=str;
    menuTreeInit();// 职业类别树初始化
    /* window.setTimeout(function () {
        $('#workDiv').OpenDiv();// 打开弹窗
    },1000) */
    $('#workDiv').OpenDiv4();// 打开弹窗
}
//职业列表初始化 start 
function menuTreeInit() {
    // ztree 配置
    var setting = {
   	    view: {
	        dblClickExpand: false
	    },
	    data: {
	        simpleData: {
	            enable: true
	        }
	    },
	    callback: {
	        beforeClick: beforeClick,
	        onDblClick: onDblClick
	    },
	    async: {
	        enable: true,
	        url:"activatedCard/queryWorkTree",// 查询下级
	        autoParam:["id"],
	        dataFilter: filter,
	        dataType: 'json'
	    }
    }
    // 展示职业树
    $.fn.zTree.init($("#ztree"), setting);
}
function beforeClick(treeId, treeNode) {
    var check = (treeNode && !treeNode.isParent);
    if (!check) $.message("error", "只能选择三级职业类型！");
    return check;
}

function onDblClick(e, treeId, treeNode) {
    var zTree = $.fn.zTree.getZTreeObj("ztree")
    var node = zTree.getSelectedNodes()
    if (node.length!=0) {
        if(flag=='0'){
            $('#workId').val(node[0].id)
            $('#workName').val(node[0].name)
            $('.workLevel').html(node[0].workLevel)
        }else if(flag=='1'){
            $('#workIdBbr').val(node[0].id)
            $('#workNameBbr').val(node[0].name)
            $('.workLevelBbr').html(node[0].workLevel)
        }
        closeWorkDiv();
    }else{
        $.message("error", "请选择职业类型！");
    }
}
//选定职业类型，点击确定
function selectWork() {
    var treeObj = $.fn.zTree.getZTreeObj("ztree");
    var node = treeObj.getSelectedNodes();
    if(node.length!=0){
    	if(flag=='0'){
            $('#workId').val(node[0].id)
            $('#workName').val(node[0].name)
            $('.workLevel').html(node[0].workLevel)
        }else if(flag=='1'){
            $('#workIdBbr').val(node[0].id)
            $('#workNameBbr').val(node[0].name)
            $('.workLevelBbr').html(node[0].workLevel)
        }
        closeWorkDiv();
    }else{
        $.message("error", "请选择职业类型！");
    }
}
function filter(treeId, parentNode, childNodes) {
    if (!childNodes) {
        return null;
    };
    var newChildNodes = $.map(childNodes, function (v, i) {
        var item = {
            'id': v.occCode,
            'pid': v.parentCode,
            'name': v.occName,
            'isParent': v.isParent,
            'workLevel':v.occLevelDesc
        }
        return item
    });
    return newChildNodes;
}
function closeWorkDiv() {
    $("#workDiv").CloseDiv4();
}
</script>
</head>
<body>
    <div class="current">
        <table class="current_table_1">
            <tbody>
                <tr class="f2">
                    <td><img src="./images/current_1.jpg"></td>
                    <td class="current_table_1_td"><img src="images/current_1.png">&nbsp;您现在的位置：&nbsp;
                        <span style="color: #136bab;">激活卡管理 <span
                            style="padding: 0 5px; font-weight: bold; line-height: 28px;">&gt;</span>激活卡激活
                            <span
                            style="padding: 0 5px; font-weight: bold; line-height: 28px;">&gt;</span>个单激活
                    </span></td>
                    <td><img src="./images/current_3.jpg"></td>
                </tr>
            </tbody>
        </table>
    </div>
    <div class="setp"><jsp:include page="../include/stepScroll.jsp"/></div>
        <input type="hidden" name="stagNo" id="stagNo" value="${stagNo}" />
        <input type="hidden" name="planNo" id="planNo" value="${insuInfo.planNo}"/>
        <input type="hidden" name="planName" id="planName" value="${insuInfo.planName}"/>
        <input type="hidden" name="partnerNo" id="partnerNo" value="${insuInfo.partnerNo}"/>
        <input type="hidden" name="appNo" id="appNo" value="${appNo}" />
        <input type="hidden" name="schoolNA" id="schoolNA" value = "${facadeAppInsured.schoolNature}" />
        <input type="hidden" name="MAX_DAYS" id="MAX_DAYS" value ="${insuInfo.maxDays}"/>
        <input type="hidden" name="MIN_DAYS" id="MIN_DAYS" value ="${insuInfo.minDays}"/>
        <input type="hidden" name="UNIR_PP" id="UNIR_PP"  value ="${insuInfo.unirPp}"/>
        <input type="hidden" name="MAX_DELAY_DAY" id="MAX_DELAY_DAY" value ="${insuInfo.maxDelayDay}"/>
        <input type="hidden" name="MIN_DELAY_DAY" id="MIN_DELAY_DAY" value ="${insuInfo.minDelayDay}"/>
        <input type="hidden" name="INSTANT" id="INSTANT" value ="${insuInfo.instant}"/>
        <input type="hidden" name="PPP_UNIT" id="PPP_UNIT" value ="${insuInfo.pppUnit}"/>
        <input type="hidden" name="global_SPECIAL_INFO" id="global_SPECIAL_INFO" value ="${insuInfo.specialInfo}"/>
        <input type="hidden" name="riskMainType" id="riskMainType" value ="${insuInfo.riskMainType}"/>
        <input type="hidden" name="pricelessType" id="pricelessType" value ="${insuInfo.cardInfo.pricelessType}"/>
        <input type="hidden" name="relWithInsuredFlag" id="relWithInsuredFlag" value ="${facadeAppApplicant.relWithInsured}"/>
        <input type="hidden" name="unitPp" id="unitPp" value ="${facadeAppForm.unirPp}"/>
        <input type="hidden" name="LAGALFALG" id="LAGALFALG" value="${LAGALFALG}"/>
        <input type="hidden" name="editFlag" id="editFlag" value="${editFlag}" />
      <div>
        <table class="table_05">
            <tbody>
                <tr>
                    <td colspan="4"
                        style="font-size: 12px; font-weight: bold; text-align: left; color: #3876bf; line-height: 17px; background-image: url(images/centent_1.jpg)">卡单信息</td>
                </tr>
                <tr>
                    <th width="25%">卡定义名称：</th>
                    <td width="28%"><input name="name" id="name" value="${insuInfo.cardInfo.name}"
                        type="text" readonly="readonly" style="background-color: #ccc;"
                        class="input_text" />
                    </td>
                    <th width="22%">卡号：</th>
                    <td width="20%"><input id="cardNo" type="text" value="${insuInfo.cardInfo.cardNo}"
                        readonly="readonly" style="background-color: #ccc;" class="input_text" />
                    </td>
                </tr>
                <tr>
                    <th>保费(元)：</th>
                    <td colspan="3"><input id="totPremamt" type="text" value="${insuInfo.cardInfo.totPremamt}"
                        readonly="readonly" style="background-color: #ccc;" class="input_text" />
                    </td>
                </tr>
                <tr>
                    <td colspan="4"
                        style="font-size: 12px; font-weight: bold; text-align: left; color: #3876bf; line-height: 17px; background-image: url(images/centent_1.jpg)">基本信息
                    </td>
                </tr>
                <tr>
                    <th>投保方案：</th>
                    <td><input name="planName" id="planName" type="text" value="${insuInfo.planName}"
                        readonly="readonly" style="background-color: #ccc;" class="input_text" />
                    </td>
                    <th>即时起保：</th>
                    <td><input type="radio" style="cursor: pointer;" <c:if test="${facadeAppForm.realSignFlag eq 'Y'}">checked</c:if> name="realSignFlag" class="realSignFlag select1" value="Y" />是
                        <input type="radio" style="cursor: pointer;" <c:if test="${facadeAppForm.realSignFlag eq 'N'}">checked</c:if> name="realSignFlag" class="realSignFlag select2" value="N" />否
                    </td>
                </tr>
<!--                 <tr style="display:none;" id="tripId"> -->
<!--                     <th>行程/航班：</th> -->
<!--                     <td colspan='3'> -->
<%--                         <input name="trip" id="trip" type="text" class="input_text" value="${facadeAppForm.trip}"/> --%>
<!--                         <span class="red">*</span> -->
<!--                     </td> -->
<!--                 </tr> -->
                <tr>
                    <th id="globalDMY">保险天数：</th>
                    <td>
                        <input name="dayCount" maxlength="7" id="dayCount" class="input_text" value="${facadeAppForm.dayCount}"/>
                        <span class="red">*</span>
                    </td>
                    <th>起保日期：</th>
                    <td>
                        <input name="effDate" id="effDate" readonly="readonly" class="input_text" value="${effDate}"/>
                        <span class="red">*</span>
                    </td>
                </tr>
<!--                 <tr> -->
<!--                     <th width="42%">投保份数：</th> -->
<!--                     <td width="53%" id="unirPpFlag"> -->
<%--                         <input name="unirPp" maxlength="15" id="unirPp" class="input_text" value="${facadeAppForm.unirPp}"> --%>
<!--                         <span class="red">*</span> -->
<!--                     </td> -->
<!--                 </tr> -->
                <tr>
                    <th>终保日期：</th>
                    <td colspan='3'>
                        <input name="termDate" id="termDate" readonly="readonly" class="input_text" value="${termDate}"/>
                    </td>
                </tr>
<!--                <tr id = "anesthTypeList"> -->
<!--                    <th width="42%">麻醉类型：</th> -->
<!--                    <td width="53%"> -->
<!--                        <select id="anesthType" name="anesthType" style="width:250px;display:inline-block;border:1px solid #c3c3c3;"> -->
<!--                                <option value="">请选择</option> -->
<%--                            <c:forEach items="${anesthTypeList}" var="anesthType"> --%>
<%--                                <option value="${anesthType.code}" <c:if test='${facadeAppFormExtend.ANESTH_TYPE eq anesthType.code}'>selected</c:if>>${anesthType.codeName}</option> --%>
<%--                            </c:forEach> --%>
<!--                        </select> -->
<!--                        <span class="red">*</span> -->
<!--                    </td> -->
<!--                 </tr> -->
<!--                 <tr name = "loanInfo"> -->
<!--                    <th>借款时间：</th> -->
<!--                    <td> -->
<%--                        <input class="input_text notNullClass" readonly name="borrowTime" id="borrowTime" value="${facadeAppForm.borrowTime}"/> --%>
<!--                        <span class="red">*</span> -->
<!--                    </td> -->
<!--                    <th>还款时间：</th> -->
<!--                    <td> -->
<%--                        <input class="input_text notNullClass" readonly name="repayTime" id="repayTime" value="${facadeAppForm.repayTime}"/> --%>
<!--                        <span class="red">*</span> -->
<!--                    </td> -->
<!--                 </tr> -->
<!--                 <tr name = "loanInfo"> -->
<!--                    <th>贷款银行网点名称：</th> -->
<!--                    <td> -->
<%--                        <input class="input_text notNullClass" name="loanBankSitename" id="loanBankSitename" maxlength="35" value="${facadeAppForm.loanBankSitename}"/> --%>
<!--                        <span class="red">*</span> -->
<!--                    </td> -->
<!--                    <th>银行联系人：</th> -->
<!--                    <td> -->
<%--                        <input class="input_text" name="bankLinkerName" maxlength="20" id="bankLinkerName" value="${facadeAppForm.bankLinkerName}"/> --%>
<!--                    </td> -->
<!--                 </tr> -->
<!--                 <tr name = "loanInfo"> -->
<!--                    <th>银行联系电话：</th> -->
<!--                    <td> -->
<%--                        <input class="input_text" name="bankLinkerPhone" maxlength="20" id="bankLinkerPhone" value="${facadeAppForm.bankLinkerPhone}"/> --%>
<!--                    </td> -->
<!--                    <th>还款方式：</th> -->
<!-- 				   <td> -->
<!-- 				      <select name="repaidType" id="repaidType" -->
<!-- 						style="width: 250px; display: inline-block; border: 1px solid #c3c3c3;"> -->
<%-- 							<c:forEach var="n" items="${repaidTypeList}"> --%>
<%-- 								<option value="${n.code}" <c:if test='${facadeAppForm.repaidType eq n.code}'>selected</c:if>>${n.codeName}</option> --%>
<%-- 							</c:forEach> --%>
<!-- 					  </select> -->
<!-- 				    </td> -->
<!-- 				</tr> -->
<!--                 <tr name = "loanInfo" > -->
<!--                    <th>保额确定方式：</th> -->
<!-- 					<td colspan='3'> -->
<!-- 					   <select name="loanWay" id="loanWay" -->
<!-- 						style="width: 250px; display: inline-block; border: 1px solid #c3c3c3;"> -->
<%-- 							<c:forEach var="n" items="${loanWayList}"> --%>
<%-- 								<option value="${n.code}" <c:if test='${facadeAppForm.loanWay eq n.code}'>selected</c:if>>${n.codeName}</option> --%>
<%-- 							</c:forEach> --%>
<!-- 					   </select> -->
<!-- 					</td> -->
<!-- 				</tr> -->
                <tr name="drivingInfo">
                    <th>车牌号：</th>
                   <td>
                       <input class="input_text notNullClass" name="plateNum" maxlength="50" id="plateNum" value="${facadeAppFormExtend.plateNum}"/>
                   </td>
                    <th>车架号：</th>
                   <td>
                       <input class="input_text notNullClass" name="chassisNum" maxlength="50" id="chassisNum" value="${facadeAppFormExtend.chassisNum}"/>
                   </td>
                </tr>
                <tr name="drivingInfo1">
                   <th name='seatNuminfo'>投保座位数：</th>
                   <td name='seatNuminfo'>
                       <input class="input_text notNullClass" name="seatNum" maxlength="10" id="seatNum" value="${facadeAppFormExtend.seatNum}"/>
                       <span class="red">*</span>
                   </td>
                </tr>
                 <%--<tr style="display:none;" id=vehicleNatureId>
                    <th>车辆性质：</th>
                    <td colspan='3'>
                        <select name="vehicleNature" id="vehicleNature"
                        style="width: 250px; display: inline-block; border: 1px solid #c3c3c3;">
                            <c:forEach var="n" items="${vehicleNatureList}">
                                <option value="${n.code}" <c:if test='${facadeAppFormExtend.vehicleNature eq n.code}'>selected</c:if>>${n.codeName}</option>
                            </c:forEach>
                       </select>
                    </td>
                </tr>--%>
                <tr style="display:none;" id=mainVehicleNatureId>
                    <th>车辆性质：</th>
                    <td colspan='3'>
                        <select name="mainVehicleNature" id="mainVehicleNature"
                                style="width: 250px; display: inline-block; border: 1px solid #c3c3c3;">
                            <c:forEach var="n" items="${mainVehicleNatureList}">
                                <option value="${n.code}" <c:if test='${facadeAppFormExtend.mainVehicleNatureStr eq n.code}'>selected</c:if>>${n.codeName}</option>
                            </c:forEach>
                        </select>
                    </td>
                </tr>
				<tr name = "ticketInfo">
                   <th>车次号：</th>
                   <td>
                       <input class="input_text" name="trainNumber" maxlength="30" id="trainNumber" value="${facadeAppFormExtend.trainNumber}"/>
                   </td>
                   <th>座位号：</th>
                   <td>
                       <input class="input_text" name="seatNumber" maxlength="10" id="seatNumber" value="${facadeAppFormExtend.seatNumber}"/>
                   </td>
                </tr>
                <tr name = "ticketInfo">
                   <th>发车时间：</th>
                   <td>
                       <input class="input_text notNullClass" name="departureTime" readonly id="departureTime" value="${facadeAppFormExtend.departureTime}"/>
                       <span class="red">*</span>
                   </td>
                   <th>到达时间：</th>
                   <td>
                       <input class="input_text notNullClass" name="arrivalTime" readonly id="arrivalTime" value="${facadeAppFormExtend.arrivalTime}"/>
                       <span class="red">*</span>
                   </td>
                </tr>
                <tr name = "ticketInfo">
                   <th>车票号：</th>
                   <td>
                       <input class="input_text" name="ticketNumber" maxlength="30" id="ticketNumber" value="${facadeAppFormExtend.ticketNumber}"/>
                   </td>
                   <th>交通工具：</th>
                   <td>
                       <select class="notNullClass" name="vehicle" id="vehicle"
                        style="width: 250px; display: inline-block; border: 1px solid #c3c3c3;">
                            <option value=''>请选择</option>
                            <c:forEach var="n" items="${vehicleList}">
                                <option value="${n.code}" <c:if test='${facadeAppFormExtend.vehicle eq n.code}'>selected</c:if>>${n.codeName}</option>
                            </c:forEach>
                       </select>
                       <span class="red">*</span>
                   </td>
                </tr>
                <tr name = "ticketInfo">
                   <th>客票号码：</th>
                   <td>
                       <input class="input_text notNullClass" name="ticketNo" maxlength="30" id="ticketNo" value="${facadeAppFormExtend.ticketNo}"/>
                       <span class="red">*</span>
                   </td>
                   <th>出发地点/起始站：</th>
                   <td>
                       <input class="input_text notNullClass" name="departureStation" maxlength="60" id="departureStation" value="${facadeAppFormExtend.departureStation}"/>
                       <span class="red">*</span>
                   </td>
                </tr>
                <tr name = "ticketInfo">
                   <th>到达地点/到达站：</th>
                   <td colspan='3'>
                       <input class="input_text notNullClass" name="arrivalStation" maxlength="60" id="arrivalStation" value="${facadeAppFormExtend.arrivalStation}"/>
                       <span class="red">*</span>
                   </td>
                </tr>
<!--                 <tr name = "trainInfo"> -->
<!--                    <th>车次号：</th> -->
<!--                    <td> -->
<%--                        <input class="input_text" name="trainNumber1" maxlength="30" id="trainNumber1" value="${facadeAppFormExtend.trainNumber}"/> --%>
<!--                    </td> -->
<!--                    <th>座位号：</th> -->
<!--                    <td> -->
<%--                        <input class="input_text" name="seatNumber1" maxlength="10" id="seatNumber1" value="${facadeAppFormExtend.seatNumber}"/> --%>
<!--                    </td> -->
<!--                 </tr> -->
<!--                 <tr name = "trainInfo"> -->
<!--                    <th>发车时间：</th> -->
<!--                    <td> -->
<%--                        <input class="input_text" name="departureTime1" readonly id="departureTime1" value="${facadeAppFormExtend.departureTime}"/> --%>
<!--                        <span class="red">*</span> -->
<!--                    </td> -->
<!--                    <th>到达时间：</th> -->
<!--                    <td> -->
<%--                        <input class="input_text" name="arrivalTime1" readonly id="arrivalTime1" value="${facadeAppFormExtend.arrivalTime}"/> --%>
<!--                        <span class="red">*</span> -->
<!--                    </td> -->
<!--                 </tr> -->
<!--                 <tr name = "trainInfo"> -->
<!--                    <th>车票号：</th> -->
<!--                    <td> -->
<%--                        <input class="input_text" name="ticketNumber1" maxlength="30" id="ticketNumber1" value="${facadeAppFormExtend.ticketNumber}"/> --%>
<!--                    </td> -->
<!--                    <th>交通工具：</th> -->
<!--                    <td> -->
<!--                        <select name="vehicle1" id="vehicle1" -->
<!--                         style="width: 250px; display: inline-block; border: 1px solid #c3c3c3;"> -->
<!--                             <option>请选择</option> -->
<%--                             <c:forEach var="n" items="${vehicleList}"> --%>
<%--                                 <option value="${n.code}" <c:if test='${facadeAppFormExtend.vehicle eq n.code}'>selected</c:if>>${n.codeName}</option> --%>
<%--                             </c:forEach> --%>
<!--                        </select> -->
<!--                    </td> -->
<!--                 </tr> -->
<!--                 <tr name = "trainInfo"> -->
<!--                    <th>客票号码：</th> -->
<!--                    <td> -->
<%--                        <input class="input_text" name="ticketNo1" maxlength="30" id="ticketNo1" value="${facadeAppFormExtend.ticketNo}"/> --%>
<!--                    </td> -->
<!--                    <th>起始站：</th> -->
<!--                    <td> -->
<%--                        <input class="input_text" name="departureStation1" maxlength="60" id="departureStation1" value="${facadeAppFormExtend.departureStation}"/> --%>
<!--                    </td> -->
<!--                 </tr> -->
<!--                 <tr name = "trainInfo"> -->
<!--                    <th>到达站：</th> -->
<!--                    <td> -->
<%--                        <input class="input_text" name="arrivalStation1" maxlength="60" id="arrivalStation1" value="${facadeAppFormExtend.arrivalStation}"/> --%>
<!--                    </td> -->
<!--                    <th>保障期间：</th> -->
<!--                    <td> -->
<!--                        <select name="rationPeriod" id="rationPeriod" -->
<!--                         style="width: 250px; display: inline-block; border: 1px solid #c3c3c3;"> -->
<%--                             <c:forEach var="n" items="${rationPeriodList}"> --%>
<%--                                 <option value="${n.code}" <c:if test='${facadeAppFormExtend.rationPeriod eq n.code}'>selected</c:if>>${n.codeName}</option> --%>
<%--                             </c:forEach> --%>
<!--                        </select> -->
<!--                        <span class="red">*</span> -->
<!--                    </td> -->
<!--                 </tr>  -->
                <tr>
                    <td colspan="4"
                        style="font-size: 12px; font-weight: bold; text-align: left; color: #3876bf; line-height: 17px; background-image: url(images/centent_1.jpg)">投保人信息
                    </td>
                </tr>
                <tr>
                   <th>投保人姓名：</th>
                   <td>
                       <input class="input_text notNullClass" name="clientName1" id="clientName1" value="${facadeAppApplicant.clientName}"/>
                       <span class="red">*</span>
                   </td>
                   <th>投保人性质：</th>
                   <td>
                       <select name="appNature" id="appNature" onchange="changeTbrIdType()" style="width:250px;display:inline-block;border:1px solid #c3c3c3;">
                          	<option <c:if test="${1 eq facadeAppApplicant.appNature}">selected="selected"</c:if> value="1">自然人</option>
							<option <c:if test="${5 eq facadeAppApplicant.appNature}">selected="selected"</c:if> value="5">企业</option>
							<option <c:if test="${7 eq facadeAppApplicant.appNature}">selected="selected"</c:if> value="7">其他社会团体</option>
							<option <c:if test="${9 eq facadeAppApplicant.appNature}">selected="selected"</c:if> value="9">军队</option>
							<option <c:if test="${10 eq facadeAppApplicant.appNature}">selected="selected"</c:if> value="10">外企</option>
							<option <c:if test="${11 eq facadeAppApplicant.appNature}">selected="selected"</c:if> value="11">村委会</option>
                       </select>
                       <span class="red">*</span>
                   </td>
                </tr>
                <tr>
                   <th>证件类型：</th>
                   <td>
                       <select name="certificateType" id="certificateType" style="width:250px;display:inline-block;border:1px solid #c3c3c3;">
                           <c:forEach var="idType" items="${idTypeList1}">
                                    <option value="${idType.code}" <c:if test="${idType.code eq facadeAppApplicant.certificateType}">selected="selected"</c:if>>${idType.codeName}</option>
                           </c:forEach>
                       </select>
                       <span class="red">*</span>
                   </td>
                   <th>证件号码：</th>
                   <td>
                       <input class="input_text notNullClass" name="certificateCode" maxlength="20" id="certificateCode" value="${facadeAppApplicant.certificateCode}"/>
                       <span class="red">*</span>
                   </td>
                </tr>
                <tr>
                   <th>出生日期：</th>
                   <td>
                       <input class="input_text notNullClass" name="clientBir1" readonly id="clientBir1" value="${facadeAppApplicant.clientBir}"/>
                       <span class="red" name="redshow">*</span>
                   </td>
                    <th>性别：</th>
                    <td><input type="radio"  style="cursor: pointer;" <c:if test='${facadeAppApplicant.sex eq 1}'>checked</c:if> name="sex1" id="sexId1" onclick="hiddedView('sexId2')" value="1"/>男
                    <input type="radio"  style="cursor: pointer;" <c:if test='${facadeAppApplicant.sex eq 2}'>checked</c:if> name="sex1" id="sexId2" onclick="hiddedView('sexId2')" value="2"/>女
                    <span class="red" name="redshow">*</span>
                    </td>
                </tr>
                <tr>
                    <th>手机号码：</th>
                    <td>
                        <input class="input_text notNullClass" name="linkmanTel1" id="linkmanTel1" value="${facadeAppApplicant.linkmanTel}"/>
                        <span class="red">*</span>
                    </td>
                    <th>电子邮箱：</th>
                    <td>
                        <input class="input_text notNullClass" name="email" id="email" value="${facadeAppApplicant.email}"/>
                        <span class="red">*</span>
                    </td>
                </tr>
                <tr>
                    <th>投保人国籍：</th>
                    <td>
                        <select name="appNationality" id="appNationality" style="width:250px;display:inline-block;border:1px solid #c3c3c3;">
                            <c:forEach var="n" items="${nationalityList}">
                                <option value="${n.code}" <c:if test="${n.code eq facadeAppApplicant.appNationality}">selected="selected"</c:if>>${n.codeName}</option>
                            </c:forEach>
                        </select>
                        <span class="red" name="redshow">*</span>
                    </td>
                    <th>职业类别：</th>
                    <td colspan='3'><input id="workName" type="text" class="input_text" style="width:170px" disabled value="${facadeAppApplicant.workTypeName}">
                        <input type="button" class="input_button_1" id="" value="选择" onClick="openWorkDiv('0')" />
                        <input id="workId" type="hidden" value="${facadeAppApplicant.workType}"/>
                        <span class="workLevel red" style="margin-left:20px;"></span>
                    </td>
                </tr>
                <tr id='commonInsure'>
                    <th>与被保人关系：</th>
                    <td colspan='3'>
                        <select name="relWithInsured1" id="relWithInsured1" style="width:250px;display:inline-block;border:1px solid #c3c3c3;">
                            <c:forEach var="rela" items="${relaList}">
                            <option value="${rela.code}" <c:if test='${facadeAppApplicant.relWithInsured eq rela.code}'>selected</c:if> >${rela.codeName}</option>
                            </c:forEach>
                        </select>
                        <span class="red">*</span>
                    </td>
                </tr>
            </tbody>
        </table>
      </div>
      <div id="drivingShow" style="display:none">
       <table class="table_05 ">
          <tr>
              <td colspan="4"
                  style="font-size: 12px; font-weight: bold; text-align: left; color: #3876bf; line-height: 17px; background-image: url(images/centent_1.jpg)">被保人信息
              </td>
          </tr>
          <tr>
            <td colspan='4'>发生保险责任范围内的交通事故时驾驶或乘坐本保险合同载明的车辆内的人员</td>
          </tr>
      </table>
      </div>
      <div class="appInsuredClass">
       <table class="table_05 ">
          <tr>
              <td colspan="4"
                  style="font-size: 12px; font-weight: bold; text-align: left; color: #3876bf; line-height: 17px; background-image: url(images/centent_1.jpg)">被保人信息
              </td>
          </tr>
          <tr>
            <th>被保人姓名：</th>
            <td><input class="input_text notNullClass" name="clientName2" id="clientName2" value="${facadeAppInsured.clientName}"/>
                <span class="red">*</span>
            </td>
            <th>证件类型：</th>
            <td>
                <select name="idType" id="idType" style="width:250px;display:inline-block;border:1px solid #c3c3c3;">
                    <c:forEach var="idType1" items="${idNature}">
                         <option value="${idType1.code}" <c:if test="${idType1.code eq facadeAppInsured.idType}">selected="selected"</c:if>>${idType1.codeName}</option>
                    </c:forEach>
                </select>
                <span class="red">*</span>
            </td>
        </tr>
        <tr >
            <th>证件号码：</th>
            <td><input class="input_text notNullClass" name="idNo" id="idNo" value="${facadeAppInsured.idNo}"/>
                 <span class="red">*</span>
            </td>
            <th>出生日期：</th>
            <td> <input readonly class="input_text notNullClass" type="text" name="clientBir2" id="clientBir2"  value="${facadeAppInsured.clientBir}"/>
            <span class="red" name='redshow'>*</span>
            </td>
        </tr>
        <tr>
            <th>性别：</th>
            <td><input type="radio" style="cursor: pointer;" <c:if test='${facadeAppInsured.sex eq 1}'>checked</c:if> name="sex2" id="sexId3" onclick="hiddedView('sexId4')"   value="1"/>男
            <input type="radio"  style="cursor: pointer;" <c:if test='${facadeAppInsured.sex eq 2}'>checked</c:if> name="sex2" id="sexId4" onclick="hiddedView('sexId4')"   value="2"/>女
            <span class="red" name='redshow'>*</span>
            </td>
            <th>手机号码：</th>
            <td><input class="input_text" name="clientTel2" id="clientTel2" value="${facadeAppInsured.clientTel}"/></td>
        </tr>
        <tr>
            <th>被保人国籍：</th>
            <td>
                <select name="insNationality" id="insNationality" style="width:250px;display:inline-block;border:1px solid #c3c3c3;">
                    <c:forEach var="n" items="${nationalityList}">
                        <option value="${n.code}" <c:if test="${n.code eq facadeAppInsured.insNationality}">selected="selected"</c:if>>${n.codeName}</option>
                    </c:forEach>
                </select>
                <span class="red" name='redshow'>*</span>
            </td>
            <th>职业类别：</th>
            <td><input id="workNameBbr" type="text" class="input_text" disabled value="${facadeAppInsured.workTypeName}">
                <input type="button" class="input_button_1" id="" value="选择" onClick="openWorkDiv('1')" />
                <input id="workIdBbr" type="hidden" value="${facadeAppInsured.workType}"/>
                <span class="workLevelBbr red" style="margin-left:20px;" ></span>
            </td>
        </tr>
        </table>
       </div>
<!--        <div class="insLineC" id="learning" style="display:none"> -->
<!--        <table class="table_05 "> -->
<!--           <tr> -->
<!--               <td colspan="4" -->
<!--                   style="font-size: 12px; font-weight: bold; text-align: left; color: #3876bf; line-height: 17px; background-image: url(images/centent_1.jpg)">学校信息 -->
<!--               </td> -->
<!--           </tr> -->
<!--           <tr> -->
<!-- 				<th>学生类别</th> -->
<!-- 				<td> -->
<!-- 				    <select name="studentType" id="studentType" style="width:250px;display: inline-block; border: 1px solid #c3c3c3;"> -->
<!-- 						<option value="">请选择</option> -->
<%-- 						<c:forEach var="n" items="${studentTypeList}"> --%>
<%-- 							<option value="${n.code}" --%>
<%-- 								<c:if test="${n.code eq facadeAppInsured.studentType}">selected="selected"</c:if>>${n.codeName}</option> --%>
<%-- 						</c:forEach> --%>
<!-- 				    </select> -->
<!--                     <span class="red">*</span> -->
<!--                 </td> -->
<!--                 <th>学校类别</th> -->
<!-- 				<td> -->
<!-- 				    <select name="schoolType" id="schoolType" style="width: 250px; display: inline-block; border: 1px solid #c3c3c3;"> -->
<!-- 						<option value="">请选择</option> -->
<%-- 						<c:forEach var="n" items="${schoolTypeList}"> --%>
<%-- 							<option value="${n.code}" --%>
<%-- 								<c:if test="${n.code eq facadeAppInsured.schoolType}">selected="selected"</c:if>>${n.codeName}</option> --%>
<%-- 						</c:forEach> --%>
<!-- 				    </select> -->
<!--                     <span class="red">*</span> -->
<!--                 </td> -->
<!-- 			</tr> -->
<!-- 			<tr> -->
<!-- 		        <th>院校类别</th> -->
<!--                 <td colspan='3'> -->
<!-- 	                <select name="schoolNature" id="schoolNature" -->
<!-- 						style="width: 220px; display: inline-block; border: 1px solid #c3c3c3;"> -->
<%-- 							<c:forEach var="n" items="${schoolNatureList}"> --%>
<%-- 								<option value="${n.code}" --%>
<%-- 									<c:if test="${'01' eq n.code}">selected="selected"</c:if>>${n.codeName} --%>
<!-- 								</option> -->
<%-- 							</c:forEach> --%>
<!-- 					</select> -->
<!--                     <span class="red">*</span> -->
<!-- 				</td> -->
<!-- 			</tr> -->
<!--         </table> -->
<!--        </div> -->
       <div id="bbrDiv">
           <table class="table_05">
               <tr>
                   <td colspan="4"
                     style="font-size: 12px; font-weight: bold; text-align: left; color: #3876bf; line-height: 17px; background-image: url(images/centent_1.jpg)">受益人信息
                   </td>
               </tr>
               <tr>
               <td colspan="4">
                  &nbsp;受益人&nbsp;&nbsp;法定&nbsp;&nbsp;
               </td>
           </tr>
           </table>
        </div>
        <br>
        <br>
        <div align="center">
           <input class="input_button_2" name="" type="button" onclick="tempSave()" value="保  存">&nbsp;&nbsp;
           <input class="input_button_2" name="" type="button" onclick="previewSubmit()" value="下一步">
        </div>
        <br>
        <!-- begin ------------------------- DIV 默认隐藏--------------------------->
    <div id="workDiv" style="display: none; width: 50%;">
        <div class="table_title_div">
            <table class="table_title" style='width: 100%; height: 20px;'>
                <tr>
                    <td width="10%"></td>
                    <td width="80%" id="interfaceName"></td>
                    <td width="10%" align="right"><img
                        src="./images/closedown.gif" alt="关闭"
                        onclick="closeWorkDiv()" /></td>
                </tr>
            </table>
        </div>
        <div class="table_title_body scroll_body">
            <ul class="ztree" id="ztree">
            </ul>
        </div>
        <div align="center">
            <input class="input_button_3" type="button" onclick="selectWork()" value="确定">&nbsp;&nbsp; 
            <input class="input_button_3" type="button" onclick="closeWorkDiv()" value="取消">
        </div>
    </div>
    <!-- end -------------------------DIV 默认隐藏---------------------------> 
</body>
</html>